//
//  MessageInformationTableViewCell.m
//  MeterMart
//
//  Created by ENERGY on 2018/10/23.
//  Copyright © 2018年 ENERGY. All rights reserved.
//

#import "MessageInformationTableViewCell.h"

@interface MessageInformationTableViewCell ()
@property (nonatomic, strong)UIImageView * iconImg;
@property (nonatomic, strong)UILabel * titleLab;
//@property (nonatomic, strong)UIImageView * redCircleImag;
//@property (nonatomic, strong)UILabel * numLab;
@property (nonatomic, strong)UIView * lineView;
@property (nonatomic, strong)UIImageView * arrowImag;

@end

@implementation MessageInformationTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        __weak typeof (self)weakSelf = self;
        self.contentView.backgroundColor = [UIColor whiteColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self.contentView addSubview:self.iconImg];
        [self.contentView addSubview:self.titleLab];
        [self.contentView addSubview:self.redCircleImag];
        [self.contentView addSubview:self.numLab];
        [self.contentView addSubview:self.lineView];
        [self.contentView addSubview:self.arrowImag];
        [self.iconImg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.contentView.mas_left).mas_offset(15/WIDTH_6_SCALE);
            make.centerY.equalTo(weakSelf.contentView.mas_centerY).mas_offset(-0.5/WIDTH_6_SCALE);
            make.width.mas_offset(16.5/WIDTH_6_SCALE);
            make.height.mas_offset(13.5/WIDTH_6_SCALE);
        }];
        [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(weakSelf.iconImg.mas_centerY);
            make.left.equalTo(weakSelf.iconImg.mas_right).mas_offset(9/WIDTH_6_SCALE);
        }];
        [self.arrowImag mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(weakSelf.contentView.mas_right).mas_offset(-15/WIDTH_6_SCALE);
            make.centerY.equalTo(weakSelf.iconImg.mas_centerY);
            make.width.mas_offset(8/WIDTH_6_SCALE);
            make.height.mas_offset(13/WIDTH_6_SCALE);
        }];
        [self.redCircleImag mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(weakSelf.arrowImag.mas_left).mas_offset(-9/WIDTH_6_SCALE);
            make.centerY.equalTo(weakSelf.iconImg.mas_centerY);
            make.width.height.mas_offset(16/WIDTH_6_SCALE);
        }];
        [self.numLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.equalTo(weakSelf.redCircleImag);
        }];
        [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.bottom.equalTo(weakSelf.contentView);
            make.height.mas_offset(1/WIDTH_6_SCALE);
        }];
    }return self;
}
- (UIImageView *)iconImg{
    if (!_iconImg) {
        _iconImg = [[UIImageView alloc] init];
        _iconImg.backgroundColor = [UIColor whiteColor];
    }return _iconImg;
}
- (UILabel *)titleLab{
    if (!_titleLab) {
        _titleLab = [[UILabel alloc] init];
        _titleLab.font = DEF_FontSize_13;
        _titleLab.textColor = [UIColor blackColor];
        _titleLab.textAlignment = NSTextAlignmentLeft;
        _titleLab.text = @"标题";
    }return _titleLab;
}
- (UIImageView *)redCircleImag{
    if (!_redCircleImag) {
        _redCircleImag = [[UIImageView alloc] init];
        _redCircleImag.backgroundColor = [UIColor redColor];
        _redCircleImag.layer.cornerRadius = 8/WIDTH_6_SCALE;
        _redCircleImag.layer.masksToBounds = YES;
    }return _redCircleImag;
}
- (UILabel *)numLab{
    if (!_numLab) {
        _numLab = [[UILabel alloc] init];
        _numLab.font = DEF_FontSize_10;
        _numLab.textColor = [UIColor whiteColor];
        _numLab.textAlignment = NSTextAlignmentCenter;
    }return _numLab;
}
- (UIView *)lineView{
    if (!_lineView) {
        _lineView = [[UIView alloc] init];
        _lineView.backgroundColor = getColor(mainColor);
    }return _lineView;
}
- (UIImageView *)arrowImag{
    if (!_arrowImag) {
        _arrowImag = [[UIImageView alloc] init];
        _arrowImag.image = [UIImage imageNamed:@"in"];
    }return _arrowImag;
}

- (void)setRegularModel:(NSDictionary *)regularModel{
    _regularModel = regularModel;
    self.titleLab.text = regularModel[@"title"];
    self.iconImg.image = [UIImage imageNamed:regularModel[@"img"]];
//    if ([regularModel[@"num"] isEqualToString:@"0"] || [regularModel[@"num"] length] == 0 || regularModel[@"num"] == nil) {
//        self.redCircleImag.hidden = YES;
//        self.numLab.hidden = YES;
//    }else{
//        self.redCircleImag.hidden = NO;
//        self.numLab.hidden = NO;
//    }

}
@end
